package com.wsoft.hr.pm.service.impl;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wsoft.hr.pm.entity.HrPmGradeOrgEntity;
import com.wsoft.hr.pm.manager.HrPmGradeOrgManager;
import com.wsoft.hr.pm.mapper.HrPmGradeOrgMapper;
import com.wsoft.hr.pm.query.grade.org.HrPmGradeOrgInsertQuery;
import com.wsoft.hr.pm.query.grade.org.HrPmGradeOrgListQuery;
import com.wsoft.hr.pm.query.grade.org.HrPmGradeOrgUpdateQuery;
import com.wsoft.hr.pm.service.IHrPmGradeOrgService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Z001
 * @Date 2025-03-01 08:35:23
 */
@Service
public class HrPmGradeOrgServiceImpl extends ServiceImpl<HrPmGradeOrgMapper, HrPmGradeOrgEntity> implements IHrPmGradeOrgService{

    @Resource
    private HrPmGradeOrgManager hrPmGradeOrgManager;

    /**
     * 考核评级组织表-分页查询
     * @param query
     * @return PageInfo
     */
    @Override
    public PageInfo<HrPmGradeOrgEntity> listHrPmGradeOrg(HrPmGradeOrgListQuery query) {
        PageHelper.startPage(query.getPageNum(), query.getPageSize());
        List<HrPmGradeOrgEntity> list = hrPmGradeOrgManager.list(query);
        return PageInfo.of(list);
    }

    /**
     * 考核评级组织表-获取详情
     * @param id
     * @return
     */
    @Override
    public  HrPmGradeOrgEntity getInfo(Long id) {
        return hrPmGradeOrgManager.getById(id);
    }

    /**
     * 新增-考核评级组织表
     * @param query
     * @return
     */
    @Override
    public boolean insertHrPmGradeOrg(HrPmGradeOrgInsertQuery query) {
        return hrPmGradeOrgManager.save(Convert.convert(HrPmGradeOrgEntity.class, query));
    }

    /**
     *  更新-考核评级组织表
     *
     * @param query
     * @return
     */
    @Override
    public boolean updateHrPmGradeOrg(HrPmGradeOrgUpdateQuery query) {
        return hrPmGradeOrgManager.updateById(Convert.convert(HrPmGradeOrgEntity.class, query));
    }

    /**
     * 删除-考核评级组织表
     * @param id
     * @return
     */
    @Override
    public boolean delete(Long id) {
        return hrPmGradeOrgManager.removeById(id);
    }
}
